<template>
    <div>
    	<div class="graybg"></div>
		<div class="header header_bg">
  			<div class="header_left">
  				<i onclick="javascript:history.back(-1)" class="iconfont baiColor">&#xe612;</i>
  			</div>
  			<div class="header_center">
  				<span class="baiColor">支付密码</span>
  			</div>
  		</div>

  		<div class="center">
  			<form action="" method="post" style="padding-top: 52px;">
	  			<input type="password"  placeholder="支付密码" v-model="pass"  />
	 
	  			<input type="password"  placeholder="确认支付密码" v-model="surepass" />
	  		</form>
  			<div class="enter button" @click="updatepass">确定</div>
  		</div>
    </div>

</template>


<script>
    export default{
    	props:["integral"],
        data(){
            return {
				pass:'',
				surepass:'',
				transferType:[], //转张类型总数据
				transferTypechecked:"" //转张类型：hzh活积分转活积分；hzy活积分转余额
            }
        },
        mounted(){
        	var integraltype = this.integral.transferType;
        	this.transferType.push(integraltype);
        	for(var i=0,len=this.transferType.length;i<len; i++){
        		if(this.transferType[i] != undefined){
        			this.transferTypechecked = this.transferType[i]
        		}
        	}
        	console.log(this.transferTypechecked)
        },
        methods:{
        	updatepass:function(){
        		var integral = this.integral;
        		var pass = this.pass;
        		var surepass = this.surepass;
        		//判断密码是否为空？是否相等？
        		if(pass == surepass){
					var info = window.localStorage.data;
					var params = new URLSearchParams();
					params.append('token', info);	//客户秘钥（信息）
					params.append('pwd',pass);
					this.$axios({
					   url:"One/Fun/verifyPayPwd",
						method:"post",
						data:params
					   }).then((res)=>{
					   	//验证密码输入是否正确，如果正确则转账成功；
					   	if(res.data.status == 1){
					   		let transferType = this.transferTypechecked;	//转张类型：hzh活积分转活积分；hzy活积分转余额
					   		
							if(transferType == "dz"){	//活积分转活积分
								let gatheringmoney = integral.price;
								let gathering = integral.s_user_id;
								
								var params = new URLSearchParams();
								params.append('token', info);	//客户秘钥（信息）
								params.append('price',gatheringmoney);
								params.append('s_user_id',gathering);
								this.$axios({
								   url:"Home/Money/dong_egral_transaction",
									method:"post",
									data:params
								}).then((res)=>{
								 	if(res.data == 0){
								 		alert("转账失败");
								 	}else if(res.data == 1){
								 		alert("转账成功");
								 		this.$router.push("wShares");
								 	}else if(res.data == 3){
								 		alert("积分不足")
								 	}else if(res.data == 4){
								 		alert("收款用户存在")
								 	}
								}).catch(function(err){
									console.log(err)		
								})
								
							}
							
					   	}else{
					   		alert("密码输入错误，请重新输入");
					   		this.pass = "";
        					this.surepass = "";
					   	}
					}).catch((err)=>{
						alert(err)		
					})
        			
        		}else if(pass == "" || surepass == ""){
        			alert("密码不能为空");
        		}else{
        			alert("两次输入密码不一致，请重新输入");
        			this.pass = "";
        			this.surepass = "";
        		}
        		
        	}
        },
    }

</script>

<style scoped="scoped">
@import "../css/public.css";
.center{
	width: 95%;
	margin: 0 auto;
}
.center form{
	width: 100%;
}
.center form input{
	padding-left: 10px;
	display: block;
	background: #FFFFFF;
	height: 14px;
	width: 97%;
	margin: 10px 0;
	height: 40px;
	line-height: 38px;
}

input::-webkit-input-placeholder{
	color: #999;
	font-size: 14px;
	line-height: 38px;
}
.center .enter{
	background: #F3961F;
	font-size: 18px;
	color: #FCFCFC;
	margin-top:128px;
	line-height: 30px;
}
</style>
